#ifndef SKILL_SYSTEM_H
#define SKILL_SYSTEM_H

#include <unordered_map>
#include <functional>
#include "skill.h"
#include "entity.h"

namespace battle {

class SkillSystem
{
public:
    SkillSystem();
    ~SkillSystem();
    
    void initialize();
    void shutdown();
    
    // 注册技能处理函数
    void register_skill(int skill_id, std::function<void(Entity*, Entity*, const SkillParams&)> handler);
    
    // 使用技能
    bool use_skill(Entity* caster, Entity* target, int skill_id, const SkillParams& params);
    
    // 检查技能冷却
    bool is_skill_on_cooldown(Entity* caster, int skill_id);
    
    // 重置技能冷却
    void reset_skill_cooldown(Entity* caster, int skill_id);
    
private:
    // 技能处理函数映射表
    std::unordered_map<int, std::function<void(Entity*, Entity*, const SkillParams&)>> skill_handlers_;
    
    // 技能冷却映射表 <caster_id, <skill_id, cooldown_end_time>>
    std::unordered_map<int64_t, std::unordered_map<int, int64_t>> skill_cooldowns_;
    
    // 内置技能处理函数
    void handle_damage_skill(Entity* caster, Entity* target, const SkillParams& params);
    void handle_buff_skill(Entity* caster, Entity* target, const SkillParams& params);
    void handle_debuff_skill(Entity* caster, Entity* target, const SkillParams& params);
    void handle_heal_skill(Entity* caster, Entity* target, const SkillParams& params);
};

} // namespace battle

#endif // SKILL_SYSTEM_H    